<!DOCTYPE html>
<html lang="en" xmlns:th="https://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>认证系统 - 登录</title>
    <link href="/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="/css/signin.css" rel="stylesheet" type="text/css"/>
    <script src="/js/jquery-3.2.1.min.js"></script>
</head>
<body>
<div class="container">
    <form class="form-signin" method="post" th:action="@{/user/login}">
        <h2 class="form-signin-heading">Please sign in</h2>
        <p>
            <label for="username" class="sr-only">Username</label>
            <input type="text" id="username" name="username" class="form-control" placeholder="Username" required autofocus>
        </p>
        <p>
            <label for="password" class="sr-only">Password</label>
            <input type="password" id="password" name="password" class="form-control" placeholder="Password" required>
        </p>
        <input type="hidden" name="redirectUrl" th:value="${redirectUrl} ?: ''" />
        <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
    </form>
    <script type="text/javascript">
        $(document).ready(function() {
            $.post('/user/isLogin', function(data) {
                if (data.data) {
                    window.location.href = $('input[name="redirectUrl"]').val();
                }
            });
        });
    </script>
</div>
</body>
</html>